package com.online.onlineshop.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.online.onlineshop.entity.Address;
import com.online.onlineshop.entity.Cart;
import com.online.onlineshop.vo.CartValueObject;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.ResultType;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface CartMapper extends BaseMapper<Cart> {

    /*
     * 查询已经加入购物车的数据购物车的数据
     * */
    @Select("SELECT\n" +
            "cart.cid,\n" +
            "cart.uid,\n" +
            "cart.pid,\n" +
            "cart.num,\n" +
            "production.title,\n" +
            "production.price AS realPrice,\n" +
            "production.image\n" +
            "FROM\n" +
            "t_cart AS cart\n" +
            "LEFT JOIN t_production as production  ON cart.pid = production.id\n" +
            "WHERE\n" +
            "cart.uid = #{uid}\n" +
            "ORDER BY\n" +
            "cart.created_time DESC")
    List<CartValueObject> getCartVOByUid(Integer Uid);

}
